package fake

import (
	"time"
	"xmediaEmu/pkg/decoder/codec"
)

type CodecData struct {
	CodecType_     codec.CodecType
	SampleRate_    int
	SampleFormat_  codec.SampleFormat
	ChannelLayout_ codec.ChannelLayout
}

func (self CodecData) Type() codec.CodecType {
	return self.CodecType_
}

func (self CodecData) SampleFormat() codec.SampleFormat {
	return self.SampleFormat_
}

func (self CodecData) ChannelLayout() codec.ChannelLayout {
	return self.ChannelLayout_
}

func (self CodecData) SampleRate() int {
	return self.SampleRate_
}

type SpeexCodecData struct {
	CodecData
}

func (self SpeexCodecData) PacketDuration(data []byte) (time.Duration, error) {
	return time.Millisecond * 20, nil
}

func NewSpeexCodecData(sr int, cl codec.ChannelLayout) SpeexCodecData {
	codeData := SpeexCodecData{}
	codeData.CodecType_ = codec.SPEEX
	codeData.SampleFormat_ = codec.S16
	codeData.SampleRate_ = sr
	codeData.ChannelLayout_ = cl
	return codeData
}
